<template>
    <div class="base-info" v-loading="loading">
        <title-bar title="基本信息"></title-bar>
        <el-form ref="form" :model="form" label-width="120px" label-position="left">
            <el-form-item label="任务名称">
                {{form.scheduleName}}
            </el-form-item>
            <el-form-item label="任务描述">
                {{form.description}}
            </el-form-item>
            <el-form-item label="实验ID">
                {{form.experimentId}}
            </el-form-item>
            <el-form-item label="创建人">
                {{form.createOper}}
            </el-form-item>
            <el-form-item label="创建时间">
                {{form.createTime}}
            </el-form-item>
            <el-form-item label="修改人">
                {{form.lastUpdateOper}}
            </el-form-item>
            <el-form-item label="最近修改时间">
                {{form.lastUpdateTime}}
            </el-form-item>
        </el-form>
        <title-bar title="调度信息"></title-bar>
        <el-form ref="form" :model="form" label-width="120px" label-position="left">
            <el-form-item label="实验调度状态">
                {{form.status?'已调度':'未调度'}}
            </el-form-item>
            <el-form-item label="调度周期">
                {{form.periodType}}
            </el-form-item>
            <el-form-item label="调度时刻">
                {{form.schedulTimeStr}}
            </el-form-item>
            <el-form-item label="最近执行时间">
                {{form.lastExecTime}}
            </el-form-item>
            <el-form-item label="下次执行时间">
                {{form.execPlan && form.execPlan[0]}}
            </el-form-item>
            <el-form-item label="调度开始日期">
                {{form.effDate}}
            </el-form-item>
            <el-form-item label="调度结束日期">
                {{form.endDate}}
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import titleBar from '@/components/TitleBar'
import { mapGetters } from 'vuex'
export default {
    name: 'BaseInfo',
    components: {
        titleBar
    },
    data () {
        return {
            loading: false,
            form: {},
            scheduleData: {}
        }
    },
    computed: {
        ...mapGetters({
            projectId: 'common/getProjectId'
        })
    },
    created () {
        this.scheduleData = JSON.parse(localStorage.getItem('scheduleData'))
        this.init()
    },
    methods: {
        init () {
            const { scheduleId, periodType, schedulTimeStr } = this.scheduleData
            this.loading = true
            let params = {
                projectId: this.projectId,
                scheduleId
            }
            this.$post('/experiment/queryOfflineSchedule', params).then(res => {
                if (res) {
                    this.form = res.rows
                    this.form.periodType = periodType
                    this.form.schedulTimeStr = schedulTimeStr
                }
            }).finally(() => {
                this.loading = false
            })
        }
    }
}
</script>
<style lang="less">
    .base-info {
        .el-form {
            .el-form-item {
                margin-bottom: 0;
                margin-left: 12px;
            }
        }
    }
</style>
